package com.ego.product.vo;

import com.ego.product.po.*;
import com.ego.product.to.coupon.SeckillSkuInfoTo;
import com.ego.product.vo.spu.Attr;
import lombok.Getter;
import lombok.Setter;

import java.util.List;

/**
 * @program: ego
 * @description: 商品详情VO
 * @author: KamTang
 * @create: 2022-12-09 15:06
 **/
@Setter
@Getter
public class DetailVo {
    /**
     * sku基本信息
     */
    SkuInfo skuInfo;

    /**
     * sku图片信息
     */
    List<SkuImage> skuImages;

    /**
     * spu销售属性组合
     */
    List<DetailSaleAttrVo> saleAttrs;

    /**
     * spu介绍
     */
    SpuInfoDesc description;

    /**
     * 规格参数信息
     */
    List<DetailSpuAttrGroupVo> attrGroups;

    /**
     * 商品秒杀信息
     */
    SeckillSkuInfoTo seckillSkuInfoTo;

    public void build(SkuInfo skuInfo,
                      List<SkuImage> skuImages,
                      List<DetailSaleAttrVo> saleAttrs,
                      SpuInfoDesc spuDescription,
                      List<DetailSpuAttrGroupVo> attrGroups) {
        this.setSkuInfo(skuInfo);
        this.setSkuImages(skuImages);
        this.setSaleAttrs(saleAttrs);
        this.setDescription(spuDescription);
        this.setAttrGroups(attrGroups);
    }


    /**
     * 商品详情销售属性VO
     */
    @Setter
    @Getter
    public static class DetailSaleAttrVo {
        private Long attrId;
        private String attrName;
        private List<AttrValueWithSkuIdVo> attrValues;

        @Setter
        @Getter
        public static class AttrValueWithSkuIdVo {
            private String attrValue;
            private List<Long> skuIds;

            public void build(String value, List<Long> skuIds) {
                this.setAttrValue(value);
                this.setSkuIds(skuIds);
            }
        }

        public void build(Long attrId, String attrName, List<AttrValueWithSkuIdVo> attrValues) {
            this.setAttrId(attrId);
            this.setAttrName(attrName);
            this.setAttrValues(attrValues);
        }
    }

    /**
     * 商品详情spu基本属性VO
     */
    @Setter
    @Getter
    public static class DetailSpuAttrGroupVo {
        private String groupName;
        private List<Attr> attrs;

        public void build(String groupName, List<Attr> spuBaseAttrs) {
            this.setGroupName(groupName);
            this.setAttrs(spuBaseAttrs);
        }
    }
}
